﻿
@model RTW.OA.Models.attend_leave
@{

    Layout = "~/Views/Shared/_LayoutBase.cshtml";
}

@section styles{

}
<div id="dMain">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="ibox" style="margin-bottom: 0px;">
            <div class="ibox-title">
                <h4>@ViewBag.Title </h4>
            </div>
            <div class="ibox-content">
                @using (Html.BeginForm("LeaveEdit", "Attend", FormMethod.Post, new { area = "Common", id = "leavefrom", name = "leavefrom" }))
                {
                    @Html.AntiForgeryToken()
				
                <div class="from-content">
                    <dl>
                        <dt>请假人</dt>
                        <dd>
                            @Html.EditorFor(m => m.USER_ID, new { htmlAttributes = new { @class = "input normal form-control", datatype = "*", nullmsg = " ", errormsg = " ", sucmsg = " " } })
                        </dd>
                    </dl>
                    <dl>
                        <dt>请假原因</dt>
                        <dd>
                            @Html.TextAreaFor(m => m.LEAVE_TYPE, new { @class = "input normal form-control", datatype = "*", nullmsg = " ", errormsg = " ", sucmsg = " " })
                        </dd>
                    </dl>
                    <dl>
                        <dt>请假开始时间</dt>
                        <dd>
                            @Html.EditorFor(m => m.LEAVE_DATE1, new { htmlAttributes = new { @Class = "input rule-date-input form-control", onfocus = "WdatePicker({ dateFmt: 'yyyy-MM-dd HH:mm:ss'})" } })
                        </dd>
                    </dl>
                    <dl>
                        <dt>请假结束时间</dt>
                        <dd>
                            @Html.EditorFor(m => m.LEAVE_DATE2, new { htmlAttributes = new { @Class = "input rule-date-input form-control", onfocus = "WdatePicker({ dateFmt: 'yyyy-MM-dd HH:mm:ss'})" } })
                        </dd>
                    </dl>
                    <dl>
                        <dt>占用年休假时间</dt>
                        <dd>
                            @Html.EditorFor(m => m.ANNUAL_LEAVE, new { htmlAttributes = new { @class = "input normal form-control" } })
                        </dd>
                    </dl>
                    <dl>
                        <dt>请假类型</dt>
                        <dd>
                            <div class="rule-single-select">
                                <select id="LEAVE_TYPE2" name="LEAVE_TYPE2" class="form-control">
                                    <option value="1">事假</option>
                                    <option value="2">病假</option>
                                    <option value="3">年假</option>
                                    <option value="9">其它</option>
                                </select>
                            </div>
                        </dd>
                    </dl>
                    <dl>
                        <dt>占用倒休时长</dt>
                        <dd>
                            <div class="rule-single-checkbox">
                                @Html.CheckBoxFor(m => m.OFF_LEAVE, new { @class = "form-control" })
                            </div>
                        </dd>
                    </dl>
                    <dl>
                        <dt>请假时长(天、小时)</dt>
                        <dd>
                            @Html.EditorFor(m => m.LEAVE_DURATION, new { htmlAttributes = new { @class = "input normal form-control" } })
                        </dd>
                    </dl>
                    <dl>
                        <dt>传阅人</dt>
                        <dd>
                            @Html.EditorFor(m => m.CIRCULATE, new { htmlAttributes = new { @class = "input normal form-control" } })
                        </dd>
                    </dl>
                    <dl>
                        <dt>审批备注</dt>
                        <dd>
                            @Html.TextAreaFor(m => m.REASON, new { @class = "input normal form-control" })
                        </dd>
                    </dl>
                    @Html.HiddenFor(m => m.LEAVE_ID)
                </div>
                    <div class="from-footer">
                        <div class="btn-wrap" style="position: fixed;">
                            <a class="btn btn-sm btn-primary radius" onclick="approval(1)">
                                <i class="iconfont icon-save"></i>
                                审批通过
                            </a>
                            <a class="btn btn-sm btn-warning radius" onclick="approval(2)">
                                <i class="iconfont icon-fanhui"></i>
                                审批不通过
                            </a>
                        </div>
                    </div>
                }
            </div>
        </div>
    </div>
</div>
@section scripts{
    <script src="@Url.Content("~/Content/JS/common/WdatePicker/WdatePicker.js")"></script>
    <script type="text/javascript" charset="utf-8" src="@Url.Content("~/Content/JS/common/jquery/Validform_v5.3.2_min.js")"></script>
    <script type="text/javascript" charset="utf-8" src="@Url.Content("~/Content/JS/common/artdialog/dialog-plus-min.js")"></script>
    <script type="text/javascript" charset="utf-8" src="@Url.Content("~/Content/JS/common/webuploader/webuploader.min.js")"></script>
    <script type="text/javascript" charset="utf-8" src="@Url.Content("~/Content/editor/ueditor.config.js")"></script>
    <script type="text/javascript" charset="utf-8" src="@Url.Content("~/Content/editor/ueditor.all.min.js")"></script>
    <script type="text/javascript" charset="utf-8" src="@Url.Content("~/Content/editor/lang/zh-cn/zh-cn.js")"></script>
    @*<script type="text/javascript" charset="utf-8" src="../js/uploader.js"></script>*@

    <script src="@Url.Content("~/Content/JS/common/from.js")"></script>
    <script>
        $(function () {
            //初始化表单验证
            $("#leavefrom").initValidform();

        });
        function savefrom() {
            parent.subcloseTab('3702');
            //$("#leavefrom").submit();
        }


        function approval(status) {
            var leaveId = $("#LEAVE_ID").val();
            var reason = $("#REASON").val();
            if (reason == "" || reason.length < 1) {
                alert("请输入审批备注");
                return false;
            }
            if (status == 2) {
                $.post("/Common/Attend/SetApproval", {
                    id: leaveId,
                    reason: reason,
                    status: status
                },
                    function (result) {
                        layer.msg('设置成功！', {
                            icon: 1,
                            time: 2000
                        }, function () {
                            parent.subcloseTab('3702');
                        });

                    });

            } else {
                layer.confirm('是否确认批示通过？', {
                    btn: ['确定', '取消'] //按钮
                }, function () {
                    $.post("/Common/Attend/SetApproval", {
                        id: leaveId,
                        reason: reason,
                        status: 1
                    }, function (result) {
                        //$("#approval-modal").modal("hide");
                        layer.msg('设置成功！', {
                            icon: 1,
                            time: 2000//2s后自动关闭
                        }, function () {
                            parent.subcloseTab('3702');
                        });
                    });
                }, function () {

                });
            }
        }


    </script>
}